/*============================================================================
  File:      lrsstatreader.h
 
  Summary:   Declaration of LRSSTATREADER class for collecting the
			 sufficient statistics for the pair-wise linear regression model.
 
  Date:		 June 30, 2004
------------------------------------------------------------------------------
  This file is part of the Microsoft SQL Server Code Samples.
 
  Copyright (C) 2003 Microsoft Corporation.  All rights reserved.
 
This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.
 
THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
============================================================================*/
#pragma once

#include "caseprocessor.h"
#include "DataValues.h"

DEFINEV(VDBL);

class LRSSTATREADER : public CASEREADER
{
  public:

	LRSSTATREADER(DMHALLOC&	dmhalloc)
		: _vvdblSumProducts(*this), _vdblSum(*this), _vdblSumSquares(*this),
		  _vdblMin(*this), _vdblMax(*this),
		  _viAttributeOutput(*this), _viAttributeInput(*this)
	{
		SetAllocator(dmhalloc);
	}

	VIEWTYPE	Viewtype()
	{
		return viewtypeDense;

	}
	
	virtual HRESULT	Initialize(CComPtr<IDMAttributeSet>& spidmattributeset);
	virtual HRESULT ProcessCaseDense(ULONG ulID, VDBL& vdblValue);
	
	// Set of inputs and outputs

	VINT	_viAttributeOutput;
	VINT	_viAttributeInput;

	// For every attribute (both input and output), we store the sum, sum of squares,
	// min, and max. For every output variattributeable we store, for every input attribute
	// the sum of products.

	VDBL	_vdblSum;			// [iAttribute]
	VDBL	_vdblSumSquares;	// [iAttribute]

	VDBL	_vdblMin;			// [iAttribute]
	VDBL	_vdblMax;			// [iAttribute]

	VVDBL	_vvdblSumProducts;	// [iiAttributeOutput][iiAttributeInput]

	UINT	_cCase;
	ULONG	_cAttribute;
	ULONG	_ciAttributeInput;
	ULONG	_ciAttributeOutput;
};
				  
